package bestTeam.WalkieDoggie.client.Composites;


import java.util.Date;

import org.cobogw.gwt.user.client.ui.Rating;

import bestTeam.WalkieDoggie.client.WalkieDoggie;
import bestTeam.WalkieDoggie.client.Serializables.UserProfileData;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class userProfileComp extends PopupPanel {
	
	private VerticalPanel verticalPanel;


	public userProfileComp(UserProfileData user,boolean isPrivate){
		super(true);

		verticalPanel = new VerticalPanel();

		this.setWidget(verticalPanel);

		HorizontalPanel horizontalPanel = new HorizontalPanel();
		verticalPanel.add(horizontalPanel);
		horizontalPanel.setWidth("100%");

		Image picture = new Image("https://graph.facebook.com/"+user.getId()+"/picture?type=small");

		horizontalPanel.add(picture);

		Anchor hprlnkFbprofile = new Anchor(user.getNickName(),false, user.getFBprofileLink(),"_blank");

		horizontalPanel.add(hprlnkFbprofile);

		horizontalPanel.setCellHorizontalAlignment(hprlnkFbprofile, HasHorizontalAlignment.ALIGN_LEFT);
		horizontalPanel.setCellVerticalAlignment(hprlnkFbprofile, HasVerticalAlignment.ALIGN_MIDDLE);

		HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
		verticalPanel.add(horizontalPanel_1);

		Label lblAddress = new Label("address:\t");
		horizontalPanel_1.add(lblAddress);
		lblAddress.setWidth("100%");

		Label lblUseraddress = null;
		if(isPrivate)
			lblUseraddress = new Label(user.getStreet()+", "+user.getCity());
		else
			lblUseraddress = new Label(user.getFullAddress());
		horizontalPanel_1.add(lblUseraddress);

		HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
		verticalPanel.add(horizontalPanel_2);

		Label lblPhone = new Label("phone:\t");
		horizontalPanel_2.add(lblPhone);
		lblPhone.setWidth("100%");

		Label label_1 = new Label(user.getPhone());
		horizontalPanel_2.add(label_1);

		HorizontalPanel horizontalPanel_3 = new HorizontalPanel();
		verticalPanel.add(horizontalPanel_3);

		/*Label lblCredit = new Label("credit:\t");
		horizontalPanel_3.add(lblCredit);
		lblCredit.setWidth("100%");

		Label label_3 = new Label(user.getCredit().toString());
		horizontalPanel_3.add(label_3);
		 */
		Label lblRank = new Label("Ranking:\t");
		horizontalPanel_3.add(lblRank);
		lblRank.setWidth("100%");

		Rating rate = new Rating((int)WalkieDoggie.loginInfo.getUserData().getRanking(), 5, Rating.LTR, "iBonesmall.png","iBoneBWsmall.png",
				"iBonesmall.png", 22, 24);
		rate.setReadOnly(true);
//		Label label_3b = new Label(user.getRanking()+"");
		horizontalPanel_3.add(rate);
		int numOfRankers = WalkieDoggie.loginInfo.getUserData().getNumberOfRankers();
		Label rankers = new Label(numOfRankers + " people rated");
		horizontalPanel_3.add(rankers);

		HorizontalPanel horizontalPanel_4 = new HorizontalPanel();
		verticalPanel.add(horizontalPanel_4);

		Label lblDogName = new Label("dog name:\t");
		horizontalPanel_4.add(lblDogName);
		lblDogName.setWidth("100%");

		Label label_2 = new Label(user.getDogName());
		horizontalPanel_4.add(label_2);

		HorizontalPanel horizontalPanel_5 = new HorizontalPanel();
		verticalPanel.add(horizontalPanel_5);

		Label lblDogGender = new Label("dog gender:\t");
		horizontalPanel_5.add(lblDogGender);
		lblDogGender.setWidth("100%");

		Label label_5 = new Label(user.getDogGender().toString());
		horizontalPanel_5.add(label_5);		
		label_5.setAutoHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		//horizontalPanel_5.setCellHorizontalAlignment(label_5, HasHorizontalAlignment.ALIGN_RIGHT);

		horizontalPanel.setSpacing(5);
		horizontalPanel_1.setSpacing(5);
		horizontalPanel_2.setSpacing(5);
		horizontalPanel_3.setSpacing(5);
		horizontalPanel_4.setSpacing(5);
		horizontalPanel_5.setSpacing(5);



		//pp.setPopupPosition(100, 100);
		//pp.show();
	}
	
	public VerticalPanel getVerticalPanel(){
		return verticalPanel;
	}
	

}